package vashion.azeroth.core.api.request;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;

import com.alibaba.fastjson.annotation.JSONField;

public class AddItemRequest extends BaseRequest {

	// 订单请求

	/**
	 * api 方法：增加商品
	 * 
	 * */
	private @Setter @Getter String method = "gy.erp.item.add";

	/**
	 * 商品代码
	 * 
	 * */
	@JSONField(name = "code")
	@NonNull
	private @Setter @Getter String code;

	/**
	 * skus规格数组
	 * 
	 * */
	@JSONField(name = "skus")
	@NonNull
	private @Setter @Getter List<Sku> skus;

	// -------------------以下参数可为空------------------------

	/**
	 * 商品名称
	 * */
	@JSONField(name = "name")
	private @Setter @Getter String name;

	/**
	 * 商品简称
	 * */
	@JSONField(name = "simple_name")
	private @Setter @Getter String simpleName;

	/**
	 * 商品类别code
	 * */
	@JSONField(name = "category_code")
	private @Setter @Getter String categoryCode;
	/**
	 * 供应商code
	 * */
	@JSONField(name = "supplier_code")
	private @Setter @Getter String supplierCode;
	/**
	 * 库存状态code
	 * */
	@JSONField(name = "stock_status_code")
	private @Setter @Getter String stockStatusCode;
	/**
	 * 重量
	 * */
	@JSONField(name = "weight")
	private @Setter @Getter Double weight;
	/**
	 * 单位code
	 * */
	@JSONField(name = "unit_code")
	private @Setter @Getter String unitCode;
	/**
	 * 销售积分
	 * */
	@JSONField(name = "sales_point")
	private @Setter @Getter Double salesPoint;
	/**
	 * 打包积分
	 * */
	@JSONField(name = "package_point")
	private @Setter @Getter Double packagePoint;
	/**
	 * 标准进价
	 * */
	@JSONField(name = "purchase_price")
	private @Setter @Getter Double purchasePrice;
	/**
	 * 标准售价
	 * */
	@JSONField(name = "sales_price")
	private @Setter @Getter Double salesPrice;
	/**
	 * 代理售价
	 * */
	@JSONField(name = "agent_price")
	private @Setter @Getter Double agentPrice;
	/**
	 * 成本价
	 * */
	@JSONField(name = "cost_price")
	private @Setter @Getter Double costPrice;
	/**
	 * 供应商货号
	 * */
	@JSONField(name = "supplier_outer_id")
	private @Setter @Getter String supplierOuterId;
	/**
	 * 备注
	 * */
	@JSONField(name = "note")
	private @Setter @Getter String note;

	@Override
	public Boolean check() {

		if (StringUtils.isEmpty(code)) {

			return false;
		}

		if (skus == null || skus.size() == 0) {
			return false;
		}

		for (Sku sku : skus) {

			if (StringUtils.isEmpty(sku.getSkuCode())
					|| StringUtils.isEmpty(sku.getSkuName())) {

				return false;
			}
		}

		return true;
	}

}
